import 'package:flutter/material.dart';

///页面卡片基类
class BaseCard extends StatefulWidget {
  @override
  BaseCardState createState() => BaseCardState();
}

class BaseCardState extends State<BaseCard> {
  Color subTitleColor = Colors.grey;
  Color bottomTitleColor = Colors.grey;

  @override
  Widget build(BuildContext context) {
    //圆角裁剪
    return PhysicalModel(
      color: Colors.transparent,
      borderRadius: BorderRadius.circular(6),
      clipBehavior: Clip.antiAlias, //抗锯齿
      child: new Container(
        decoration: BoxDecoration(color: Colors.white),
        child: new Column(
          children: <Widget>[topContent(), bottomContent()],
        ),
      ),
    );
  }

  //构建上部的View
  Widget topContent() {
    return new Padding(
      padding: EdgeInsets.only(left: 20, top: 26, right: 20, bottom: 20),
      child: new Column(
        mainAxisAlignment: MainAxisAlignment.start,
        crossAxisAlignment: CrossAxisAlignment.start,
        children: <Widget>[
          Row(
            crossAxisAlignment: CrossAxisAlignment.end,
            children: <Widget>[topTitle(''), smallTopTitle('')],
          ),
          subTitle('')
        ],
      ),
    );
  }

  //构建底部的view
  Widget bottomContent() {
    return Container();
  }

  //构建副标题
  Widget subTitle(String title) {
    return new Padding(
      padding: EdgeInsets.only(top: 5),
      child: Text(
        title,
        style: new TextStyle(color: subTitleColor, fontSize: 11),
      ),
    );
  }

  //构建顶部标题
  Widget topTitle(String topTitle) {
    return new Text(
      topTitle,
      style: TextStyle(fontSize: 22),
    );
  }

  //构建顶部小的标题
  Widget smallTopTitle(String smallTopTitle) {
    return new Padding(
      padding: EdgeInsets.all(5),
      child: Text(
        smallTopTitle,
        style: new TextStyle(fontSize: 10, color: Colors.black45),
      ),
    );
  }

  //构建底部的小标题
  Widget bottomTitle(String title) {
    return new Text(
      title,
      style: new TextStyle(fontSize: 15, color: bottomTitleColor),
    );
  }
}
